<div class="wrapper">
    <div class="list-filter-form">
        <@bolt.queryForm path="system" id="query_org_form" dataGrid="sys_org_select_table"></@bolt.queryForm>
    </div>
<table id="sys_org_select_table">
    <thead>
    <tr>
        <th data-options="{field:'name', align:'center', width:250, rule:'required'}">名称</th>
        <th data-options="{field:'areaName', align:'center', width:120}">所在区域</th>
        <th data-options="{field:'tel', align:'center', width:120}">电话</th>
        <th data-options="{field:'email', align:'center', width:150}">邮箱</th>
        <th data-options="{field:'enabled',align:'center', width:100,formatter:Page.Org.Select.state}">是否可用</th>
    </tr>
    </thead>
</table>
</div>
<script type="application/javascript">
    $.namespace('Page.Org.Select');
    Page.Org.Select = function () {
        return {
            initTreeTable: function () {
                $('#sys_org_select_table').boltDataGrid({
                    width:'100%',
                    height:'full-180',
                    treeView: true,
                    paging: false,
                    queryParams:{enabled:1},
                    dataUrl: '${base}/admin/sys/org/getOrgList'
                })
            },
            state: function (data) {
                if (data) {
                    return '<span class="label  label-primary ">已启用</span>';
                } else {
                    return '<span class="label label-warning">已禁用</span>';
                }
            },
            selectNode: function () {
                var data = $('#sys_org_select_table').boltDataGrid('getSelections');
                if(!data){
                    Bolt.notify("warning", "请选择机构");
                    return;
                }
                Bolt.bringBack(data[0]);
            }
        }
    }();

    $(document).ready(function () {
        Page.Org.Select.initTreeTable();
    });
</script>
